from flask import Flask, flash, jsonify, Response, render_template, request, session, redirect, url_for
import simplejson as json
from flask_session import Session
from apps.admin import app,db

@app.route('/upload', methods=['GET', 'POST'])
def upload_file():
    if request.method == 'POST':
        f = request.files['file']
        print(request.files)
        # f.save(secure_filename(f.filename))
        return 'file uploaded successfully'
    else:
        return render_template('test/upload.html')


@app.route('/hello/<name>')
def hello_name(name):
    return 'Hello %s!' % name


@app.route('/my')
def my():
    marks = 50
    mydict = {"name":"张三", "Physics":78, "Chemistry":85, "Mathematics": 90}

    user = {
        'username': 'Grey Li',
        'bio': 'A boy who loves movies and music.',
    }

    movies = [
        {'name': 'My Neighbor Totoro', 'year': '1988'},
        {'name': 'Three Colours trilogy', 'year': '1993'},
        {'name': 'Forrest Gump', 'year': '1994'},
        {'name': 'Perfect Blue', 'year': '1997'},
        {'name': 'The Matrix', 'year': '1999'},
        {'name': 'Memento', 'year': '2000'},
        {'name': 'The Bucket list', 'year': '2007'},
        {'name': 'Black Swan', 'year': '2010'},
        {'name': 'Gone Girl', 'year': '2014'},
        {'name': 'CoCo', 'year': '2017'},
    ]
    
    return render_template("test/my.html", name="zhibin", marks = marks, result=mydict, user=user, movies=movies)